//
//  LPCoustomFortyFourImageViewAndLabelView.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPCoustomFortyFourImageViewAndLabelView.h"

@implementation LPCoustomFortyFourImageViewAndLabelView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        [self addGestureRecognizer:tap];
        [self addSubview:self.imageView];
        [self addSubview:self.label];
    }
    return self;
}

/**  点击方法  */
- (void)tapClick:(UITapGestureRecognizer *)tap{
    if (self.delegate && [self.delegate respondsToSelector:@selector(lpFortyFourWithView:click:)]) {
        [self.delegate lpFortyFourWithView:self click:YES];
    }
}

- (UILabel *)label{
    if (!_label) {
        _label = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, self.width, 10)];
            label.textAlignment = NSTextAlignmentCenter;
            label.textColor = [UIColor whiteColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:13 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _label;
}


- (UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake((self.width - 22) / 2, 4, 22, 22)];
        _imageView.contentMode = UIViewContentModeCenter;
    }
    return _imageView;
}
@end
